<?php

/*
#======================================
#	Zameleon.Alpha 2
#   ==========================
#	By David Sims
#	davidsims@thatphpguy.com
#	==========================
#	Version: v1.0 Alpha 2
#======================================
*/

#=============================
# Set environment
#=============================
ini_set('register_globals', 0);

if ( @ini_get('register_globals') )
{
	while ( list($key, $value) = each($_REQUEST) )
	{
		unset( $$key );
	}
}

@set_time_limit(0);
ob_start('ob_gzhandler');

ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_NOTICE);

#=============================
# Constants
#=============================
define('SITE_PATH', './');

require_once constant('SITE_PATH') . 'includes/classes.php';
$zam = new zameleon();

#=============================
# Choice pages
#=============================
if ( !$zam->sess->is_logged_in() )
{
	$private = array(
		'login'    	=> 	'login',
		'register' 	=> 	'register',
	);
}
else
{	
	$private = array(
		'profile'	=>	'profile',
		'signout'	=>	'misc'
	);
}

$public = array(
	'main' 		=> 	'misc',
	'user'		=>	'profile'
);

$pages = @array_merge($private, $public);

#=============================
# Run module
#=============================
if ( !empty($zam->data['params'][1]) )
{
	$required_path = constant('SITE_PATH') . 'modules/' . $pages[ $zam->data['params'][1] ] . '.php';

	if ( file_exists( $required_path ) )
	{
		$rp = $required_path;
	}
	else
	{
		$rp = constant('SITE_PATH') . 'modules/' . $pages['main'] . '.php';
	}
}
else
{
	$rp = constant('SITE_PATH') . 'modules/' . $pages['main'] . '.php';
}

require_once $rp;
$init = new module();
$init->zam = &$zam;
$init->main();

# Close MySQL
$zam->sql->close();

?>